Skip to content

fix(config): corrige le log d'avertissement des variables ${VAR} abse… - #296

Merged
NICE-DEV226 merged 1 commit into
mainfrom
fix/config-missing-env-warning
Oct 13, 2026
Merged

NICE-DEV226 merged 1 commit into
mainfrom
fix/config-missing-env-warning

Conversation

@NICE-DEV226

@NICE-DEV226 NICE-DEV226 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

…ntes

_resolve passait la variable en argument positionnel à un message sans marqueur de formatage : chaque variable d'environnement absente produisait une « Logging error » (TypeError de formatage avalé par logging) au lieu d'un avertissement lisible. La variable est maintenant un champ structuré, comme le demande la convention du dépôt.

Le comportement de résolution est inchangé : une variable absente donne une chaîne vide. Test de non-régression qui échoue avant le correctif.

Summary by Sourcery

Corrige le traitement des avertissements pour les variables d’environnement absentes sans modifier leur comportement de résolution.

Bug Fixes:

  • Corrige l’avertissement émis lorsque des variables d’environnement absentes sont résolues, afin d’éviter les erreurs de formatage du module logging tout en conservant la résolution en chaîne vide.

Tests:

  • Ajoute des tests de non-régression couvrant les variables absentes et définies, y compris la résolution dans les structures imbriquées.

…ntes

_resolve passait la variable en argument positionnel à un message sans
marqueur de formatage : chaque variable d'environnement absente produisait
une « Logging error » (TypeError de formatage avalé par logging) au lieu d'un
avertissement lisible. La variable est maintenant un champ structuré, comme
le demande la convention du dépôt.

Le comportement de résolution est inchangé : une variable absente donne une
chaîne vide. Test de non-régression qui échoue avant le correctif.
Copilot AI balanced review requested due to automatic review settings October 13, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Le correctif conserve le comportement de résolution des variables ${VAR} tout en réparant l’avertissement des variables absentes via un champ structuré var, avec des tests couvrant la sortie résolue et l’absence d’erreur de formatage logging.

File-Level Changes

Change Details Files
Corriger l’émission de l’avertissement lorsqu’une variable d’environnement est absente en utilisant un champ de log structuré plutôt qu’un argument positionnel non consommé.
  • Remplacer le message anglais et l’argument positionnel par un message français avec var=var.
  • Conserver la résolution des variables absentes en chaîne vide et la substitution des variables définies.
xcore/configurations/helper.py
Ajouter des tests de non-régression couvrant la résolution et l’absence d’erreurs de formatage du logging.
  • Vérifier les résolutions dans des dictionnaires, listes et chaînes avec variable absente.
  • Intercepter les erreurs de handlers logging et confirmer qu’aucune erreur n’est produite.
  • Vérifier la substitution d’une variable d’environnement définie.
tests/unit/test_config_env_warning.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@NICE-DEV226
NICE-DEV226 merged commit cb36ed6 into main Oct 13, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="xcore/configurations/helper.py" line_range="25" />
<code_context>
+        logging.Handler,
+        "handleError",
+        lambda self, record: erreurs.append(record),
+    )
+    monkeypatch.delenv("XCORE_TEST_VAR_ABSENTE", raising=False)
+
</code_context>
<issue_to_address>
**Config can forge text log lines**

When an attacker-controlled configuration contains an unresolved `${...}` placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, `_resolve` passes the captured variable name as `var`, and `_TextFormatter.format` inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.

Escape or remove control characters from structured field values before rendering them in the text formatter.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: xcore/configurations/helper.py:25


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

extra={"var": var},
"variable d'environnement non définie, chaîne vide utilisée",
var=var,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Config can forge text log lines

When an attacker-controlled configuration contains an unresolved ${...} placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, _resolve passes the captured variable name as var, and _TextFormatter.format inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.

Escape or remove control characters from structured field values before rendering them in the text formatter.

Prompt for AI agents
In `xcore/configurations/helper.py` at line 25:

**Config can forge text log lines**

When an attacker-controlled configuration contains an unresolved `${...}` placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, `_resolve` passes the captured variable name as `var`, and `_TextFormatter.format` inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.

Escape or remove control characters from structured field values before rendering them in the text formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants